package com.learn.disruptor.basic.translator;

import com.learn.disruptor.basic.event.LongEvent;
import com.lmax.disruptor.EventTranslatorOneArg;
import com.lmax.disruptor.EventTranslatorThreeArg;
import com.lmax.disruptor.EventTranslatorTwoArg;
import com.lmax.disruptor.EventTranslatorVararg;
import com.lmax.disruptor.RingBuffer;

/**
 * @author huangChao
 * @see EventTranslatorOneArg 一个参数
 * @see EventTranslatorTwoArg 二个参数
 * @see EventTranslatorThreeArg 三个参数
 * @see EventTranslatorVararg 多个参数
 **/
public record LongEventTranslator(Long id)
    implements EventTranslatorOneArg<LongEvent, RingBuffer<LongEvent>>
{

    /**
     * 载入事件
     * @param event    old事件
     * @param sequence 执行序列(递增)
     * @param arg0     传递参数
     */
    @Override
    public void translateTo(LongEvent event, long sequence, RingBuffer arg0) {
        event.setId(id);
    }
}
